<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/17
 * Time: 16:01
 */
namespace app\wechat\controller;

use app\wechat\service\LoginService;
use think\Request;

class Login {

    public function index()
    {
        echo 1;
    }

    public function doLogin(Request $request) {
        $return = [
            'code' => '999999',
            'data' => []
        ];
        $code = $request->post('code');
        $user_id = LoginService::doLogin($code);
        if (!empty($user_id)) {
            $return = [
                'code' => '000000',
                'data' => [
                    'user_id' => $user_id
                ]
            ];
        }
        return json($return);
    }
}